﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectSem3.Admin
{
    public partial class WebForm17 : System.Web.UI.Page
    {
        private DataClassesHeaxlthDataContext dc = new DataClassesHeaxlthDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string id = Request.QueryString["id"];
                if (id == null)
                {
                    Response.Redirect("Company.aspx");
                }
                else
                {
                    CompanyDetail comp = this.dc.CompanyDetails.Single(c => c.companyid.Equals(id));
                    this.companyname.Value = comp.companyname;
                    this.phone.Value = comp.phone;
                    this.address.Value = comp.address;
                    this.companyurl.Value = comp.companyurl;
                }
            }
        }

        protected void ButtonUpdate_Click(object sender, EventArgs e)
        {
            string companyname = this.companyname.Value;
            string phone = this.phone.Value;
            string address = this.address.Value;
            string url = this.companyurl.Value;
            update(companyname, phone, address, url);
        }
        public void update(string companyname, string phone, string address, string url)
        {
            string id = Request.QueryString["id"];
            CompanyDetail com = this.dc.CompanyDetails.Single(p => p.companyid.Equals(id));
            com.companyname = companyname;
            com.phone = phone;
            com.address = address;
            com.companyurl = url;
            this.dc.SubmitChanges();
            this.Labelkq.Text = "Update Successful";
        }
    }
}